home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
fifth21.arc
/
MANDEL.FIV
< prev
next >
Wrap
Text File
|
1986-04-23
|
5KB
|
268 lines
CREATE MANDEL
CREATE MACHINE
EDIT
( TI=0 / IBM=1 Machine flag)
1 constant machine
~UP
CREATE XMAX
CREATE X
EDIT
( Maximum X for this machine)
: x machine if 225 else 720 endif ;
~UP
EDIT
( Maximum X value)
x constant xmax
~UP
CREATE YMAX
CREATE Y
EDIT
: y machine if 200 else 300 endif ;
~UP
EDIT
y constant ymax
~UP
CREATE GCLS
EDIT
: GCLS cls 4 vmode
0 0 0 xmax 1- ymax 1- FILLBOX
;
~UP
CREATE DIS
EDIT
: dis
8 0 do
i 0 palette
loop
;
~UP
CREATE H#
EDIT
\ Hex constant
: h# base @ 16 base ! ' ['] literal execute base ! ; immediate
~UP
CREATE R87
EDIT
\ Parse a following 8087 register ==> stack element 0-7.
: r87
' dup 8 u< not abort" Register must be 0-7"
;
~UP
CREATE POP?
EDIT
\ 8087 operation & POP if trailing P : FADD P1 ==> FADDP ST(1)
: pop?
>in @
begin
dup c@@ dup 32 = over 13 = or over 10 = or swap 9 = or while
1+ repeat
dup c@@ dup 80 = swap 112 = or
if 1+ >in ! h# DE c,
else drop h# D8 c, endif
;
~UP
CREATE FINIT
EDIT
\ Initilize 8087
: finit
h# DB c, h# E3 c, ; immediate
~UP
CREATE FLD
EDIT
\ Load real to 8087 stack & pop Fifth stack
: fld
h# 9B c, \ FWAIT
h# D9 c, h# 46 c, h# 00 c, \ FLD [BP+0]
h# 83 c, h# C5 c, h# 04 c, \ ADD BP,4
h# 9B c, \ FWAIT
; immediate
~UP
CREATE FSTP
EDIT
\ Push 8087 real to Fifth stack, pop from 8087.
: fstp
h# 9B c, \ FWAIT
h# 83 c, h# C5 c, h# FC c, \ ADD BP,-4
h# D9 c, h# 5E c, h# 00 c, \ FSTP [BP+0]
h# 9B c, \ FWAIT
; immediate
~UP
CREATE FPICK
EDIT
\ PICK a value on the 8087 stack, must be 0-7: FPICK87 3
: fpick
r87
h# 9B c, \ FWAIT
h# D9 c, h# C0 + c, \ FLD ST(i)
; immediate
~UP
CREATE FSWAP
EDIT
\ Exchange 8087 TOS with the nth register, must be 0-7
: fswap
r87
h# 9B c, \ FWAIT
h# D9 c, h# C8 + c, \ FXCH ST(i)
; immediate
~UP
CREATE FPOP
EDIT
\ Drop an 8087 value
: fpop
h# 9B c, \ FWAIT
h# D9 c, h# D8 c, \ FSTP ST(0)
; immediate
~UP
CREATE FADD
EDIT
\ Add two 8087 numbers
: fadd
h# 9B c, \ FWAIT
pop? r87 h# C0 + c, \ FADD ST(i)
; immediate
~UP
CREATE FMUL
EDIT
\ Multiply two 8087 numbers
: fmul
h# 9B c, \ FWAIT
pop? r87 h# C8 + c, \ FMUL ST(i)
; immediate
~UP
CREATE FSUB
EDIT
\ Subtract two 8087 numbers
: fsub
h# 9B c, \ FWAIT
pop? r87 h# E0 + c, \ FSUB ST(i)
; immediate
~UP
CREATE FSUBR
EDIT
\ Subtract reversed two 8087 numbers
: fsubr
h# 9B c, \ FWAIT
pop? r87 h# E8 + c, \ FSUBR ST(i)
; immediate
~UP
CREATE FDIV
EDIT
\ Divide two 8087 numbers
: fdiv
h# 9B c, \ FWAIT
pop? r87 h# F0 + c, \ FDIV ST(i)
; immediate
~UP
CREATE FDIVR
EDIT
\ Divide reversed two 8087 numbers
: fdivr
h# 9B c, \ FWAIT
pop? r87 h# F8 + c, \ FDIVR ST(i)
; immediate
~UP
CREATE H
EDIT
variable h
~UP
CREATE DRAW
CREATE X
EDIT
\ Real part start
-2. constant x
~UP
CREATE Y
EDIT
\ Imaginary part start
-2. constant y
~UP
CREATE SX
EDIT
\ Size of real part
4. constant sx
~UP
CREATE SY
EDIT
\ Size of imagniary part
4. constant sy
~UP
CREATE GX
EDIT
\ Real pixel gap
sx xmax i->f f/ constant gx
~UP
CREATE GY
EDIT
\ Imaginary pixel gap
sy ymax i->f f/ constant gy
~UP
CREATE XC
EDIT
\ real corner of pixel in progress
variable xc
~UP
CREATE YC
EDIT
\ imaginary corner of pixel in progress
variable yc
~UP
CREATE CNT
EDIT
\ count of iterations until z explodes
variable cnt
~UP
CREATE SETUP
EDIT
: setup finit 2. fld -2. dup fld fld 0. dup fld fld ;
~UP
CREATE .FS
EDIT
: .fs
fstp fstp fstp fstp
dup . fld dup . fld dup . fld dup . fld ;
~UP
CREATE FOUR
EDIT
4. constant four
~UP
CREATE DRAW2
EDIT
\ Exploring the Mandelbrot set
: draw2
fpick 0 fmul 0 fpick 2 fmul 0 fpick 0 fadd 2 fstp
fsub p1 fadd 3
fpick 5 fmul 2 fmul 3 fadd 5
fswap 3 fpop fswap 1 fpop
.fs ;
~UP
EDIT
\ Exploring the Mandelbrot set
: draw
xmax 0 do y gy f- yc !
gx i i->f f* x f+
ymax 0 do dup
gy yc @ f+ dup yc !
finit -2. fld fld fld 0 fld 0 fld
64 cnt !
64 1 do
fpick 0 fmul 0 fpick 2 fmul 0 fpick 0 fadd 2 fstp
fsub p1 fadd 3
fpick 5 fmul 2 fmul 3 fadd 5
fswap 3 fpop fswap 1 fpop
four > if i cnt ! leave endif loop
cnt @ j i pset
loop drop ?term if key drop abort endif
loop
;
~UP
EDIT
: mandel
gcls
begin 1 while
draw
repeat
key drop
;
~UP
ABORT